package com.yidian.controller;

import com.yidian.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author whb
 * @create 2021-05-08 16:57
 * @desciption 公共异常处理类
 */
@ControllerAdvice //指明此类是一个控制器通知类
public class BaseExceptionHandle {
    @ExceptionHandler(Exception.class) //指定检测的异常类型
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        System.out.println("调用公共异常处理类..");
        return new Result(1,e.getMessage());
    }
}
